package net.yxsoft.controller.pc.sysmgt.common.validator;

import com.jfinal.core.Controller;
import net.yxsoft.controller.common.validator.BaseValidator;
import net.yxsoft.model.infrastructure.TsDatamodelProperties;
import rapid.core.ContextStateEnum;
import rapid.core.TResult;

/**
 * Created by Administrator on 2016/6/28.
 */

public class DataModelValidator extends BaseValidator {
 /**
 * @MethodName: validate
 * @Description:
 * @param: c
 * @return void
 * @throws
 * @date 2023/8/31 15:36
 * @author jhf
 */
  protected void validate(Controller c) {

    setShortCircuit(true);

    validateRequired("attrib_descn", "title_Valid", "属性名称不能为空。");
    validateByteString("attrib_descn", 1, 100, "title_Valid", "属性名称最多为100字节。");
  }
 /**
 * @MethodName: handleError
 * @Description:
 * @param: c
 * @return void
 * @throws
 * @date 2023/8/31 15:36
 * @author jhf
 */
  protected void handleError(Controller c) {
    TResult _result = new TResult();
    c.keepPara(TsDatamodelProperties.class);
    _result.setState(ContextStateEnum.FAIL);
    _result.setMessage(c.getAttr("title_Valid").toString());
    c.renderJson(_result);
  }

}
